<template>
  <a-card :bordered="false" style="border-radius: 10px;">

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="6" :sm="8">
            <a-form-item label="剧本名称">
              <a-input placeholder="请输入剧本名称" v-model="goodName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <a-form-item label="店铺名称">
              <a-input placeholder="请输入店铺名称" v-model="shopName"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8" >
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>

        </a-row>
      </a-form>
    </div>
    <!-- table区域-begin -->
    <div>
      <a-table
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        @change="handleTableChange">
        <template slot="imgSlot" slot-scope="text">
          <!-- <ul v-if="text.length>0" style="list-style:none;">
            <li v-for="val in text">
              <div @click="jumpProview(val)">
                <img :src="val" height="25px" style="max-width:80px;font-size: 12px;font-style: italic;"/>
              </div>
            </li>
          </ul> -->
          <a-carousel v-if="text.length>1" arrows style="width:100px;margin:0 auto;" class="carSty">
            <div
              slot="prevArrow"
              slot-scope="props"
              class="custom-slick-arrow"
              style="left: 10px;zIndex: 1"
            >
              <a-icon type="left-circle" />
            </div>
            <div slot="nextArrow" slot-scope="props" class="custom-slick-arrow" style="left:114px;">
              <a-icon type="right-circle" />
            </div>
            <div v-for="val in text" style="width:50%;" @click="jumpProview(val)">
              <img :src="val" style="width:100px;height:100px;">
            </div>
          </a-carousel>
          <img v-if="text.length==1" @click="jumpProview(text)" :src="text" style="width:100px;height:100px;">
          <span v-if="text.length==0" style="font-size: 12px;font-style: italic;">无此图片</span>
        </template>
      </a-table>
    </div>
    <JProviewImg v-if="showImg" @closeProview="closeProview" :imgurl="proviewUrl"></JProviewImg>
  </a-card>
</template>

<script>
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import { getAction } from '@/api/manage'
  import JProviewImg from '@/components/jeecg/JProviewImg'

  export default {
    name: "BlockPlayCommentBeforeList",
    mixins:[JeecgListMixin],
    components: {
      JProviewImg
    },
    data () {
      return {
        description: '剧本评论管理页面',
        dataSource:[],
        issuerId:"",
        userAuth2btn:"",
        goodName:"",
        shopName:"",
        ipagination: {
          current: 1,
          pageSize: 10,
          pageSizeOptions: ['10', '20', '30'],
          showTotal: (total, range) => {
            return range[0] + '-' + range[1] + ' 共' + total + '条'
          },
          showQuickJumper: true,
          showSizeChanger: true,
          total: 0
        },
        // 表头
        columns: [
          {
            title:'店家名',
            align:"center",
            dataIndex: 'userName'
          },
          {
            title:' 店家手机号码',
            align:"center",
            dataIndex: 'userPhone'
          },
          {
            title:' 剧本名称',
            align:"center",
            dataIndex: 'goodName'
          },
          {
            title:'店铺名称',
            align:"center",
            dataIndex: 'shopName'
          },
          {
            title:'门店地址',
            align:"center",
            dataIndex: 'shopAddress'
          },
          {
            title:'内容',
            width:"15%",
            align:"center",
            dataIndex: 'content'
          },
          {
            title:'评分',
            align:"center",
            dataIndex: 'start'
          },
          {
            title:'图片',
            align:"center",
            width:260,
            dataIndex: 'imgList',
            scopedSlots: { customRender: 'imgSlot' }
          }
        ],
		url: {
          list: "https://blockinsight.com.cn/scriptPlay/third/commentList",
          delete: "/exhibition/exhibition_play_comment/delete",
          deleteBatch: "/exhibition/exhibition_play_comment/deleteBatch",
          exportXlsUrl: "exhibition/exhibition_play_comment/exportXls",
          importExcelUrl: "exhibition/exhibition_play_comment/importExcel",
       },
      proviewUrl:"",
      showImg:false,
    }
  },
    mounted() {
      var that = this;
      getAction("/block/blockManufacturerInfo/userAuth2btn")
        .then(res => {
          if (res.success) {
            that.userAuth2btn = res.result.status;
            if(that.userAuth2btn == 3){
              that.issuerId = "";
              this.listInfo();
              return
            }
            let list={
              column: "createTime",
              order: "desc",
              field: "id,,factoryName,companyProfile,createTime,type,name,status,address,phone,imageurl,action",
              pageNo: 1,
              pageSize: 5
            };
            getAction("/block/blockManufacturerInfo/list",list).then((res)=>{
              if (res.success) {
                this.issuerId = res.result.records[0].id;
                this.listInfo();
              } else {
                this.$message.warning(res.message)
              }
            })
          } else {
            this.$message.warning(res.message)
          }
        })
        .finally(() => {
          this.loading = false
        }) 
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      }
    },
    methods: {
      listInfo(){
        getAction("https://blockinsight.com.cn/scriptPlay/third/commentList?currentPage=1&pageSize=10&issuerId="+this.issuerId).then((res) => {
        if (res.success) {
          this.dataSource = res.data.data;
          this.ipagination.total = res.data.totalSize;
        }
        if(res.code===510){
          this.$message.warning(res.message)
        }
      })
      },
      closeProview(){
        this.showImg = false;
      },
      jumpProview(val){
        this.showImg = true;
        this.proviewUrl = val;
      },
      handleTableChange(pagination, filters, sorter){
        getAction("https://blockinsight.com.cn/scriptPlay/third/commentList?currentPage="+pagination.current+"&pageSize=10&goodName="+this.goodName+"&shopName="+this.shopName+"&issuerId="+this.issuerId).then((res) => {
          if (res.success) {
            this.dataSource = res.data.data;
            this.ipagination.total = res.data.totalSize;
          }
          if(res.code===510){
            this.$message.warning(res.message)
          }
        })
      },
      searchReset(){
        this.goodName = "";
        this.shopName = "";
        this.searchQuery();
      },
      searchQuery(){
        this.ipagination.current = 1;
        getAction("https://blockinsight.com.cn/scriptPlay/third/commentList?currentPage=1&pageSize=10&goodName="+this.goodName+"&shopName="+this.shopName+"&issuerId="+this.issuerId).then((res) => {
          if (res.success) {
            this.dataSource = res.data.data;
            this.ipagination.total = res.data.totalSize;
          }
          if(res.code===510){
            this.$message.warning(res.message)
          }
        })
      }
    }
  }
</script>
<style scoped>
  /* @import '~@assets/less/common.less' */

  .carSty /deep/ .slick-prev{
    left: -40px !important;
  }

  .carSty /deep/ .slick-slide{
    text-align: center;
    height: 100px;
    line-height: 100px;
    background: #fff;
    /* overflow: hidden; */
  }
  .carSty /deep/ .custom-slick-arrow {
    width: 25px;
    height: 25px;
    font-size: 25px;
    color: #364d79;
    background-color: rgba(31, 45, 61, 0.11);
    opacity: 0.3;
  }
  .carSty /deep/ .custom-slick-arrow:before {
    display: none;
  }
  .carSty /deep/ .custom-slick-arrow:hover {
    opacity: 0.5;
  }

  .carSty /deep/ .slick-slide h3 {
    color: #fff;
  }

  .carSty /deep/ .slick-list{
    width:100px;
  }
</style>